import yaml
from goods_feedback.config.setting import *

class doYaml:

    def __init__(self):
        pass

    @staticmethod
    def get_data(file_path):
        # 将文件下的yml文件读取出来

        with open(file_path,encoding='utf-8') as f:
            #解析基本的yaml文件
            data=yaml.safe_load(f)
        return data

    #load将字符串变成字典
    #dump将字典变成字符串
    #load_all 生成一个迭代器
    #load将字典和列表混合结构

    @staticmethod
    def get_datas(file_path):
        #定义一个data变量，将data.yml的文件读取出来
        list_d=[]
        with open(file_path,encoding='utf-8') as f:
            datas=yaml.safe_load_all(f)
            for data in datas:
                list_d.append(data)

        return list_d
